#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from fastapi import APIRouter, Depends, Request, Response, UploadFile
from fastapi.security import OAuth2PasswordRequestForm
from loguru import logger

from app.api import jwt
from app.api.service import user_service
from app.api.service import workhour_service

from app.common.pagination import Page
from app.common.response.response_schema import response_base
from app.models import User
from app.schemas.token import Token
from app.schemas.user import Auth, CreateUser, GetUserInfo, ResetPassword, UpdateUser, ELCode, Auth2
from app.schemas.project import StartProjectTimer,CreateProjectTimer


workhour = APIRouter()


@workhour.get('/', description='获取所有的工时信息')
async def start_work(current_user: User = Depends(jwt.get_current_user)):
    projects = await workhour_service.get_workhour_project_by_user(current_user)
    return projects
    # current_user: User = Depends(jwt.get_current_user)
    # count = await user_service.update_avatar(username=username, current_user=current_user, avatar=avatar)
    # if count > 0:
    #     return response_base.response_200(msg='更新头像成功')
    # return response_base.fail()



@workhour.post('/', description='创建一个工时项目')
async def create_workhour_project(obj: CreateProjectTimer):
    await workhour_service.create_workhour_project(obj)
    return response_base.response_200(msg='工时项目创建成功')
    



 
@workhour.post('/start', description='开始工时计时')
async def start_work(obj,current_user: User = Depends(jwt.get_current_user)):
    pass
    await workhour_service.create_workhour_project(obj)
    return response_base.response_200(msg='工时项目创建成功')



 